<%= render :partial => 'vish_editor.full' %>

<script>	
	options = {};
	var configuration = {};

	configuration["ImagesPath"] = "/assets/";
	configuration["StylesheetsPath"] = "/assets/";

	configuration["uploadPresentationPath"] = "<%= excursion_path @excursion, :format=> "json" %>";
	configuration["previewPresentationPath"] = "/excursions/preview";

	configuration["uploadImagePath"] = "<%= documents_path :format=> "json"%>";
	configuration["uploadObjectPath"] = "<%= documents_path :format=> "json"%>";
	configuration["uploadPDF2PPath"] = "<%= pdfexes_path :format=> "json"%>";
	configuration["uploadEPackagesPath"] = "<%= documents_path :format=> "json"%>";
	configuration["enableFileImportation"] = true;

	// Sources enabled
	configuration["ViSH"] = true;
	configuration["ViSH_instances"] = ["<%= Vish::Application.config.full_domain %>"];
	configuration["Flickr"] = true;
	<% unless Vish::Application.config.APP_CONFIG['EuropeanaAPIKEY'].nil? %>
		configuration["Europeana"] = true;
		configuration["EuropeanaAPIKEY"] =  "<%= Vish::Application.config.APP_CONFIG['EuropeanaAPIKEY'] %>";
	<% end %>
	<% unless Vish::Application.config.APP_CONFIG['YouTubeAPIKEY'].nil? %>
		configuration["Youtube"] = true;
		configuration["YoutubeAPIKEY"] =  "<%= Vish::Application.config.APP_CONFIG['YouTubeAPIKEY'] %>";
	<% end %>
	configuration["LRE"] = true;
	configuration["LRE_path"] = "/lre/search";
	<% unless Vish::Application.config.APP_CONFIG['soundCloudAPIKEY'].nil? %>
		configuration["SoundCloud"] = true;
		configuration["SoundCloudAPIKEY"] =  "<%= Vish::Application.config.APP_CONFIG['soundCloudAPIKEY'] %>";
	<% end %>

	//Thumbnails
	configuration["thumbnailsPath"] = '/thumbnails.json';
	
	//Tags
	configuration["tagsPath"] = "/tags.json?mode=popular&limit=100";
	
	//TmpJSON
	configuration["uploadJSONPath"] = "/excursions/tmpJson.json";

	//Attachment (not for new excursions)
	configuration["uploadAttachmentPath"] = "/excursions/attachments.json";
	

	configuration["presentationSettings"] = true;

	var tagsSettings = new Object();
	tagsSettings.maxLength = '<%=Vish::Application.config.tagsSettings["maxLength"]%>';
	tagsSettings.maxTags = '<%=Vish::Application.config.tagsSettings["maxTags"]%>';
	tagsSettings.triggerKeys = <%=raw(Vish::Application.config.tagsSettings["triggerKeys"].to_json)%>;     	
	configuration["tagsSettings"] = tagsSettings;
	
	<% if available_services.include? "Catalogue" %>
		configuration["catalog"] = <%= raw Vish::Application.config.catalogue["categories"].map{|c| c.capitalize}.to_json %>;
	<% end %>

	configuration["publishPermissions"] = ["Comment","Download","Clone"]

	options["configuration"] = configuration;
	options["developping"] = false;
	

	options["environment"] = {
		name: "<%= Vish::Application.config.name %>"
	}

	<% unless current_subject.admin? %>
		options["user"] = {
			name: "<%= current_subject.name %>",
			id: "<%= Actor.normalize_id(current_subject) %>",
			token: "<%= form_authenticity_token %>"
		};
	<% else %>
		options["user"] = {
			name: "<%= @excursion.owner.name %>",
			id: "<%= Actor.normalize_id(@excursion.owner) %>",
			token: "<%= form_authenticity_token %>"
		};
	<% end %>

	<% unless current_subject.private_student_group_id == nil %>
		configuration["notifyTeacherPath"] = '/private_student_groups/notify_teacher';
		configuration["userMode"] = "student";
		options["notified"] = <%= @excursion.notified_teacher.to_s %>
	<% end %>

	options["draft"] = <%= @excursion.draft.to_s %>;

	options["lang"] = "<%= I18n.locale.to_s%>";

	<% if current_subject %>
		<% if @excursion.draft.to_s == "false" %>
			options["exitURL"]  = "<%= excursion_path(@excursion) %>";
		<% else %>
			options["exitURL"]  = "<%= url_for(current_subject) %>";
		<% end %>
	<% end %>

	options.addons = [];

	var addon = new Object();
	addon.target = "Both";
	addon.id = "IframeMessenger";
	addon.config = {enable: true};
	options.addons.push(addon);

	function start(){
		VISH.Editor.init(options, <%= raw @excursion.to_json%> );
	}
</script>
